home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / profdirserviceprovider / nsProfileDirServiceProvider.h
C/C++ Source or Header  |  2006-05-08  |  5KB  |  146 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 2002
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Conrad Carlen <ccarlen@netscape.com>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. // Interfaces Needed
  40. #include "nsIDirectoryService.h"
  41. #include "nsILocalFile.h"
  42.  
  43. #include "nsCOMPtr.h"
  44. #include "nsDirectoryServiceUtils.h"
  45. #include "nsComponentManagerUtils.h"
  46. #include "nsServiceManagerUtils.h"
  47.  
  48. #ifdef MOZILLA_INTERNAL_API
  49. #include "nsString.h"
  50. #else
  51. #include "nsEmbedString.h"
  52. #endif
  53.  
  54. // Forward Declarations
  55. class nsProfileLock;
  56.  
  57. // --------------------------------------------------------------------------------------
  58. // nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
  59. // profile-relative file locations.
  60. // --------------------------------------------------------------------------------------
  61.  
  62. class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
  63. {  
  64.   NS_DECL_ISUPPORTS
  65.   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
  66.  
  67.   friend nsresult NS_NewProfileDirServiceProvider(PRBool, nsProfileDirServiceProvider**);
  68.  
  69. public:
  70.  
  71.    /**
  72.     * SetProfileDir
  73.     *
  74.     * @param aProfileDir   The directory containing the profile files.
  75.     *                      It does not need to exist before calling this
  76.     *                      method. If it does not, it will be created and
  77.     *                      defaults will be copied to it. 
  78.     * @param aLocalProfileDir
  79.     *                      Directory for local profile data, e.g. Cache.
  80.     *                      If null, aProfileDir will be used for this purpose.
  81.     */
  82.  
  83.    virtual nsresult        SetProfileDir(nsIFile* aProfileDir,
  84.                                          nsIFile* aLocalProfileDir = nsnull);
  85.  
  86.   /**
  87.    * Register
  88.    *
  89.    * Convenience method to register the provider with directory service.
  90.    * The service holds strong references to registered providers so consumers
  91.    * don't need to hold a reference to this object after calling Register().
  92.    */
  93.  
  94.   virtual nsresult         Register();
  95.  
  96.   /**
  97.    * Shutdown
  98.    *
  99.    * This method must be called before shutting down XPCOM if this object
  100.    * was created with aNotifyObservers == PR_TRUE. If this object was
  101.    * created with aNotifyObservers == PR_FALSE, this method is a no-op.
  102.    */
  103.  
  104.   virtual nsresult         Shutdown();
  105.  
  106. protected:
  107.                            nsProfileDirServiceProvider(PRBool aNotifyObservers = PR_TRUE);
  108.    virtual                 ~nsProfileDirServiceProvider();
  109.  
  110.   nsresult                 Initialize();
  111.   nsresult                 InitProfileDir(nsIFile* profileDir);
  112.   nsresult                 InitNonSharedProfileDir();
  113.   nsresult                 EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir);
  114.   nsresult                 UndefineFileLocations();
  115.  
  116. protected:
  117.  
  118.   nsCOMPtr<nsIFile>        mProfileDir;
  119.   nsCOMPtr<nsIFile>        mLocalProfileDir;
  120.   nsProfileLock*           mProfileDirLock;
  121.   PRPackedBool             mNotifyObservers;
  122.  
  123.   PRPackedBool             mSharingEnabled;
  124. #ifndef MOZILLA_INTERNAL_API
  125.   nsEmbedString            mNonSharedDirName;
  126. #else
  127.   nsString                 mNonSharedDirName;
  128. #endif
  129.   nsCOMPtr<nsIFile>        mNonSharedProfileDir;
  130. };
  131.  
  132.  
  133. // --------------------------------------------------------------------------------------
  134.  
  135. /**
  136.  * Global method to create an instance of nsProfileDirServiceProvider
  137.  *
  138.  * @param aNotifyObservers    If true, will send out profile startup
  139.  *                            notifications when the profile directory is set.
  140.  *                            See nsIProfileChangeStatus.
  141.  */
  142.  
  143. nsresult NS_NewProfileDirServiceProvider(PRBool aNotifyObservers,
  144.                                          nsProfileDirServiceProvider** aProvider);
  145.  
  146.